<?php 

include $_SERVER['DOCUMENT_ROOT'].'/online-system/freenew/model/WeiInfo.class.php';
include $_SERVER['DOCUMENT_ROOT'].'/online-system/freenew/model/ToDatabase.class.php';
include $_SERVER['DOCUMENT_ROOT'].'/online-system/freenew/controller/Controller.php';

$operation = isset($_GET['operation']) ? htmlspecialchars($_GET['operation']) : '';


if($operation == "reservation"){
	$data['phone'] = isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '';
	$data['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
	$data['date'] = isset($_POST['date']) ? htmlspecialchars($_POST['date']) : '';
	$data['time'] = isset($_POST['time']) ? htmlspecialchars($_POST['time']) : '';
	$data['desk'] = isset($_POST['desk']) ? htmlspecialchars($_POST['desk']) : '';
	$data['dish'] = isset($_POST['dish']) ? htmlspecialchars($_POST['dish']) : '';
	$data['backup'] = isset($_POST['backup']) ? htmlspecialchars($_POST['backup']) : '';
	$data['openid'] = $_COOKIE["openid"];
	//var_dump($data);
	$TD = new ToDatabase();
	$judge = $TD->insertReservation($data);
	$TD->insertDishs($data);
	echo $judge;
	


}else if($operation == "insertdish"){
	
	$data['name'] = isset($_POST['dish']) ? htmlspecialchars($_POST['dish']) : '';
	$data['phone'] = isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '';
	$data['desk'] = isset($_POST['desk']) ? htmlspecialchars($_POST['desk']) : '';
	$data['openid'] = $_COOKIE["openid"];
	
	date_default_timezone_set("PRC");
	$data['time'] = date("Y-m-d H:i:s");
	
	$TD = new ToDatabase();
	$judge	= $TD->insertDishs($data);
	echo $judge;
	
}else if($operation == "register") {
	
		$member = array();
		//$member['openid'] = 'os9qxtydN4HgcBTBX9AStCkvpOiU';
		//$member['phone'] = '13687177529';
		//$member['name'] = '年后';
	$member['openid'] = $_COOKIE["openid"];
	$member['phone'] = isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '';
	$member['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';

	$TD = new ToDatabase;
	$judge = $TD->uoiMember($member);
	 
	 echo $judge;
	
}else{
	
	
}





?>
